package com.shtel.customeraccount.controller;

import com.shtel.customeraccount.entity.AcconutInfo;
import com.shtel.customeraccount.entity.ConsumerInfo;
import com.shtel.customeraccount.entity.RechargeInfo;
import com.shtel.customeraccount.service.CustomerAccountService;
import com.shtel.customeraccount.util.Cors;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;
import java.util.List;

@Api(description = "账户信息服务接口")
@RestController
public class CustomerAccountController extends Cors {
    @Autowired
    CustomerAccountService customerAccountService;

    //查询充值缴费记录
    //310320199506061234
    @ApiOperation(value = "查询充值缴费记录", notes = "查询充值缴费记录")
    @GetMapping("queryrechargeinfo/{creditnum}")
    public List<RechargeInfo> queryrechargeinfo(@PathVariable String creditnum) {
        return customerAccountService.queryrechargeinfo(creditnum);

    }

    //查询消费记录
    @ApiOperation(value = "查询消费记录", notes = "查询消费记录")
    @GetMapping("queryconsumerinfo/{creditnum}")
    public List<ConsumerInfo> queryconsumerinfo(@PathVariable String creditnum) {

        return customerAccountService.queryconsumerinfo(creditnum);

    }

    //查询关联银行卡、翼支付账号
    @ApiOperation(value = "查询关联银行卡、翼支付账号", notes = "查询关联银行卡、翼支付账号")
    @GetMapping("queryacconutinfo/{creditnum}")
    public AcconutInfo queryacconutinfo(@PathVariable String creditnum) {
        return customerAccountService.queryacconutinfo(creditnum);

    }
    @ApiOperation(value = "python测试接口", notes = "python测试接口")
    @GetMapping("/api/smart_model")
    public String testpytho(){
        RestTemplate rs = new RestTemplate();
        rs.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        System.out.println("1111");
        String url="http://47.98.126.229:8000/api/smart_model/?format=json";
        return rs.getForObject(url,String.class);

    }


}
